﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Guia.Elements;
using Guia.Core;
using WpfTestApplication;

namespace GuiaTest
{
    /// <summary>
    /// Summary description for ExpanderTest
    /// </summary>
    [TestClass]
    public class ExpanderTest : AbstractWindowTest
    {
        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize]
        // public void MyTestInitialize()
        // {
        //   base.MyTestInitialize();
        // }
        // 
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup]
        // public void MyTestCleanup()
        // {
        // base.MyTestCleanup();
        // }
        //
        #endregion

        protected override Type TestWindowType()
        {
            return typeof(ExpanderTestWindow);
        }

        protected override string TestWindowName()
        {
            return "ExpanderTestWindow";
        }

        [TestMethod]
        public void TestExpand()
        {
            Expander expander = this.window.Get<Expander>("expander1");
            expander.Expand();
            Assert.IsTrue(expander.IsExpanded);

            //to be sure
            Label label1 = this.window.Get<Label>("label1");
            Assert.IsNotNull(label1);
        }

        [TestMethod]
        public void TestIsExpanded()
        {
            Expander expander = this.window.Get<Expander>("expander1");
            expander.IsExpanded = true;
            Assert.IsTrue(expander.IsExpanded);
            expander.IsExpanded = false;
            Assert.IsFalse(expander.IsExpanded);
        }

        [TestMethod,ExpectedException(typeof(ElementNotFoundException))]
        public void TestCollapse()
        {
            Expander expander = this.window.Get<Expander>("expander1");
            expander.Collapse();
            Assert.IsFalse(expander.IsExpanded);

            //to be sure (throws exception)
            Label label1 = this.window.Get<Label>("label1");
        }
    }
}
